﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Twipler.App.Parse.Code;
using Xunit;
using Xunit.Extensions;

namespace UnitTests.App.Parse.Code
{
    public class SimpleTypes
    {
        [Theory]
        [InlineData(67890)]
        [InlineData(12345)]
        [InlineData(-35)]
        [InlineData(12334.2342333)]
        [InlineData(-12334.2342333)]
        [InlineData("Hello world T9 ")]
        [InlineData("Hello \\ wor T8 ld")]
        [InlineData("Hello \" wor T7 ld")]
        [InlineData("Hello \\\"w T6 ld")]
        [InlineData("HeT5  \\ \" world")]
        [InlineData("T4\\ \" world\\")]
        [InlineData("\\T3")]
        [InlineData("\"T2 ")]
        [InlineData(" \"T1")]
        [InlineData("")]
        public void ParseType(object expect)
        {
            object result = expect;

            if (expect is string)
               expect = string.Format("\"{0}\"", ((string)expect).Replace("\\","\\\\").Replace("\"", "\\\""));

            TokenParser parser = new TokenParser(expect.ToString());

            TokenParser.Result resultToken = parser.Next(TokenParser.TokenType.Any);

            Assert.NotNull(resultToken);
            Assert.Equal(resultToken.Is, TokenParser.Token.Value);
            Assert.Equal(resultToken.Value, result);
        }
    }
}
